﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TaiwuZD
{
    public class TwGongFa : TwObject
    {
        public static Dictionary<int, string> TwGongFaTypes { get; private set; } = new Dictionary<int, string> {
            { 101,"内功" },{ 102,"身法" },{ 103,"绝技" }  ,{ 104,"拳掌" },{ 105,"指法" } ,{ 106,"腿法" },{ 107,"暗器" }  ,{ 108,"剑法" },{ 109,"刀法" },
            { 110,"长兵" },{ 111,"奇门" }  ,{ 112,"软兵" },{ 113,"御射" }  ,{ 114,"乐器" }};

        public static Dictionary<int, string> TwGongFaSchools { get; private set; } = new Dictionary<int, string> {
           { -1,"全部" },{ 1,"少林派" },{ 2,"峨眉派" },{ 3,"百花谷" }  ,{ 4,"武当派" },{ 5,"元山派" } ,{ 6,"狮相门" },{ 7,"然山派" }  ,{ 8,"璇女派" },{ 9,"铸剑山庄" },
            { 10,"空桑派" },{ 11,"金刚宗" }  ,{ 12,"五仙教" },{ 13,"界青门" }  ,{ 14,"伏龙坛" } ,{ 15,"血犼教" } , { 0,"无门派" }};


        private int _Proficiency;
        private int _Degree;
        private int _Reverse;

        public int TypeId { get { return ValueAt<int>(61); } }


        /// <summary>
        /// 修习程度
        /// </summary>
        public int Proficiency
        {
            get { return _Proficiency; }
            set { _Proficiency = Math.Min(Math.Max(0, value), 100); }
        }

        /// <summary>
        /// 心法等级
        /// </summary>
        public int Degree
        {
            get { return _Degree; }
            set { _Degree = Math.Min(Math.Max(0, value), 10); }
        }

        /// <summary>
        /// 逆练
        /// </summary>
        public int Reverse
        {
            get { return _Reverse; }
            set { _Reverse = Math.Min(Math.Max(0, value), 10); }
        }


        public int Level { get { return ValueAt<int>(2); } }


        /// <summary>
        /// 门派
        /// </summary>
        public int SchoolId { get { return Id % 10000 / 100; } }

        public string SchoolName { get { return GetSchoolName(SchoolId); } }


        public static string GetSchoolName(int id)
        {
            if (TwGongFaSchools.ContainsKey(id))
                return TwGongFaSchools[id];
            else
                return "无门派"; 
        }

        public override object Clone()
        {
            var rr = new TwGongFa() { Name = this.Name, Id = this.Id, Description = this.Description };
            return rr;
        }

        protected override string GetDefaultValue(string key)
        {
            if (GameAssets.TwGongFas != null)
            {
                if (GameAssets.TwGongFas.ContainsKey(Id))
                    if (GameAssets.TwGongFas[Id].DataShop.ContainsKey(key))
                        return GameAssets.TwGongFas[Id].DataShop[key];
            }

            return base.GetDefaultValue(key);
        }
    }
}
